package com.cyjt.operation.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.cyjt.operation.R;
import com.cyjt.operation.bean.DynamicNodes;

/**
 * 动态交通车位动态节点的Adapter
 * 
 * @author LTP
 *
 */
public class DynamicNodesAdpter extends ArrayAdapter<DynamicNodes> {
	private int listViewItemResorce;

	public DynamicNodesAdpter(Context context, int resource, List<DynamicNodes> objects) {
		super(context, resource, objects);
		// TODO 构造方法
		listViewItemResorce = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		DynamicNodes dynamicNodes = getItem(position);
		ViewHolder mViewHolder;
		if (convertView == null) {
			convertView = LayoutInflater.from(getContext()).inflate(listViewItemResorce, null);
			mViewHolder = new ViewHolder();
			mViewHolder.textView_dynamic_nodes_code = (TextView) convertView
					.findViewById(R.id.textView_dynamic_nodes_code);
			mViewHolder.textView_dynamic_nodes_nfcCode = (TextView) convertView
					.findViewById(R.id.textView_dynamic_nodes_nfcCode);
			mViewHolder.textView_dynamic_nodes_crossing = (TextView) convertView
					.findViewById(R.id.textView_dynamic_nodes_crossing);
			mViewHolder.textView_dynamic_nodes_driveway = (TextView) convertView
					.findViewById(R.id.textView_dynamic_nodes_driveway);
			convertView.setTag(mViewHolder);
		} else {
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		mViewHolder.textView_dynamic_nodes_code.setText(dynamicNodes.getCode() + "");
		mViewHolder.textView_dynamic_nodes_nfcCode.setText(dynamicNodes.getNfcCode() + "");
		mViewHolder.textView_dynamic_nodes_crossing.setText(dynamicNodes.getCrossing() + "");
		mViewHolder.textView_dynamic_nodes_driveway.setText(dynamicNodes.getDriveway() + "");
		return convertView;
	}

	class ViewHolder {
		/** 基站编码文本 */
		TextView textView_dynamic_nodes_code;
		/** 节点编码文本 */
		TextView textView_dynamic_nodes_nfcCode;
		/** 路口方向文本 */
		TextView textView_dynamic_nodes_crossing;
		/** 车道数文本 */
		TextView textView_dynamic_nodes_driveway;
	}
}
